import java.util.Arrays;

public class Bit {
    public static boolean isHave(int[] array){
        /*int i = 0;
        while(i < array.length){
            if(array[i]%2 == 0){
                i += 1;
            }else if(array[i+1]%2 == 0){
                i += 2;
            }else if(array[i+2]%2 == 0){
                i += 3;
            }else {
                return true;
            }
        }*/
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i]%2 != 0 ){
                count++;
                if(count == 3){
                    return true;
                }
            }else {
                count = 0;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        int[] array = {1,2,34,3,4,5,7,23,12};
        boolean ret = isHave(array);
        System.out.println(ret);
    }
    public static void main8(String[] args) {
        int[] array = {2,2,2,1,1};
        int ans = 0;
        int count = 0;
        for (int i = 0; i < array.length; i++){
            if(count == 0){
                count++;
                ans = array[i];
            }else if(ans == array[i]){
                count++;
            }else{
                count--;
            }
        }
        System.out.println(ans);
    }
    public static int findOne(int[] array){
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }
    public static void main7(String[] args) {
        int[] array = {1,1,5,6,6};
        int ret = findOne(array);
        System.out.println(ret);
    }
    public static String findN(int[] array, int target) {
        if(array == null)
            return null;
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if(array[i] + array[j] == target) {
                    return "[" + i + "," + j + "]";
                }
            }
        }
        return "未找到";
    }
    public static void main6(String[] args) {
        int[] array = {4,7,11,15,2};
        String ret = findN(array, 9);
        System.out.println(ret);
    }
    public static void main5(String[] args) {
        int[] array = {1,9,2,5,7,8};
        for (int i = 0; i < array.length - 1; i++) {
            int flag = -1;
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] > array[j+1]){
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    flag = 1;
                }
            }
            if(flag == -1)
                break;
        }
        System.out.println(Arrays.toString(array));
    }
    public static void main4(String[] args) {
        int[] a = {1,2,3,4,5,6,7};
        int left = 0;
        int right = a.length - 1;
        while(left < right){
            while(left < right && a[left]%2 != 0 ){
                left++;
            }
            while (left < right && a[right]%2 == 0){
                right--;
            }
            int tmp = a[left];
            a[left] = a[right];
            a[right] = tmp;
        }
        System.out.println(Arrays.toString(a));
    }
    public static double avg(int[] array){
        double sum = 0.0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
        return sum / array.length;
    }

    public static void main3(String[] args) {
        int[] a = {2,4,6,8,10};
        double avg = avg(a);
        System.out.println(avg);
    }
    public static int[] transform(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i] * 2;
        }
        return array;
    }

    public static void main2(String[] args) {
        int[] a = {1,2,3,4,5};
        int[] ret = transform(a);
        System.out.println(Arrays.toString(ret));
    }


    public static String myToString(int[] array) {
        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];
            if(i != array.length-1){
                ret += ",";
            }
        }
        ret += "]";
        return ret;
    }

    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5};
        String ret = myToString(array);
        System.out.println(ret);
    }
}
